package artid.com.arttogoa.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import artid.com.arttogoa.R;
import artid.com.arttogoa.parser.FolderBean;

public class FolersAdapter extends BaseAdapter {
	private Context mContext;
	LayoutInflater mInflater;
	private List<FolderBean> folderList;
	ViewHolder holder;

	public FolersAdapter(Context mContext, List<FolderBean> folderList) {
		this.mContext = mContext;
		this.folderList = folderList;
		mInflater = LayoutInflater.from(mContext);
	}

	@Override
	public int getCount() {
		return folderList.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		if (convertView == null) {
			vh = new ViewHolder();
			convertView = mInflater.inflate(R.layout.item_folers_list, null);
			vh.name = (TextView) convertView.findViewById(R.id.tv_name);
			vh.count = (TextView) convertView.findViewById(R.id.tv_count);
			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}
		FolderBean fb = folderList.get(position);
		vh.name.setText(fb.getName());
		vh.count.setText(fb.getFileCount());
		return convertView;
	}

	class ViewHolder {
		TextView name, count;
		ImageView iv;
	}
}
